﻿<!--
Copyright © 2011 François Karman

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

See<license.txt>for the complete license of the software.
-->
<UserControl x:Class="NUnit.Phone.Gui.TestList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             FontFamily="{StaticResource PhoneFontFamilyNormal}"
             FontSize="{StaticResource PhoneFontSizeNormal}"
             Foreground="{StaticResource PhoneForegroundBrush}"
             d:DesignHeight="480"
             d:DesignWidth="480">

    <UserControl.Resources>
        <Style x:Key="InvisibleButtonStyle"
               TargetType="Button">
            <Setter Property="BorderThickness"
                    Value="0" />
            <Setter Property="Background"
                    Value="Transparent" />
        </Style>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!-- The displayed test -->
        <StackPanel Grid.Row="0"
                    Orientation="Vertical">
            <TextBlock Text="{Binding Path=Name}"
                       Style="{StaticResource PhoneTextTitle2Style}"
                       TextWrapping="Wrap" />
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=TestCaseCount}"
                           Style="{StaticResource PhoneTextSubtleStyle}"
                           Margin="12,0,0,0" />
                <TextBlock Text="/"
                           Style="{StaticResource PhoneTextSubtleStyle}"
                           Margin="0" />
                <TextBlock Text="{Binding Path=TestCaseCount}"
                           Style="{StaticResource PhoneTextSubtleStyle}"
                           Margin="0" />
                <TextBlock Text=" - "
                           Style="{StaticResource PhoneTextSubtleStyle}"
                           Margin="0" />
                <TextBlock Text="{Binding Path=RunState}"
                           Style="{StaticResource PhoneTextSubtleStyle}"
                           Margin="0" />
            </StackPanel>

            <!-- Its properties - if any -->
            <ItemsControl ItemsSource="{Binding Path=Properties}"
                          Margin="12,0">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=Name}" />
                            <TextBlock Text=": " />
                            <TextBlock Text="{Binding Path=Value}" />
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </StackPanel>

        <!-- Its children -->
        <ListBox Grid.Row="1"
                 ItemsSource="{Binding Path=Tests}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Button Click="OnChildClick"
                            Style="{StaticResource InvisibleButtonStyle}">
                        <StackPanel>
                            <TextBlock Text="{Binding Path=Name}"
                                       Style="{StaticResource PhoneTextTitle2Style}"
                                       TextWrapping="Wrap" />
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Path=TestCaseCount}"
                                           Style="{StaticResource PhoneTextSubtleStyle}"
                                           Margin="12,0,0,0" />
                                <TextBlock Text="/"
                                           Style="{StaticResource PhoneTextSubtleStyle}"
                                           Margin="0" />
                                <TextBlock Text="{Binding Path=Parent.TestCaseCount}"
                                           Style="{StaticResource PhoneTextSubtleStyle}"
                                           Margin="0" />
                            </StackPanel>
                        </StackPanel>
                    </Button>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>
